#include "thread_ring_queue.hpp"
// #include "Task.hpp"
#include <iostream>
#include <pthread.h>
#include <unistd.h>
#include <ctime>

void *Consumer(void *args)
{
    RingQueue<int> *c = static_cast<RingQueue<int> *>(args);
    while (true)
    {
        int out = 0;
        c->Pop(&out);
        std::cout << "Consumer pop data-> " << out << std::endl;
        //sleep(1);
    }
}
void *Productor(void *args)
{
    RingQueue<int> *q = static_cast<RingQueue<int> *>(args);
    while (true)
    {
        int in = rand() % 100 + 1;
        q->Push(in);
        std::cout << "Productor push data-> " << in << std::endl;
        // sleep(1);
    }
}

int main()
{
    srand(time(nullptr) ^ getpid());
    pthread_t c, p;
    RingQueue<int> *rq = new RingQueue<int>;
    pthread_create(&c, nullptr, Consumer, (void *)rq);
    pthread_create(&p, nullptr, Productor, (void *)rq);

    pthread_join(c, nullptr);
    pthread_join(p, nullptr);
    return 0;
}